package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sc.nft.entity.vo.merchantPledgeTask.AdminCycleConfVO;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.MerchantPledgeTaskCycleConf;
import com.sc.nft.mapper.MerchantPledgeTaskCycleConfMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 商户质押任务周期表(sc_merchant_pledge_task_cycle_conf)数据DAO
 *
 * @author Sun
 * @since 2023-08-24 16:16:49
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class MerchantPledgeTaskCycleConfDao extends ServiceImpl<MerchantPledgeTaskCycleConfMapper, MerchantPledgeTaskCycleConf> {

    public List<AdminCycleConfVO> getCycleListAndRewardsDetailsByTaskId(Long id) {
        return baseMapper.getCycleListAndRewardsDetailsByTaskId(id);
    }

    public List<MerchantPledgeTaskCycleConf> getCycleListByPledgeTaskConfId(Long merchantPledgeTaskId) {
        LambdaQueryWrapper<MerchantPledgeTaskCycleConf> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MerchantPledgeTaskCycleConf::getMerchantPledgeTaskId,merchantPledgeTaskId);
        return list(wrapper);
    }

    public MerchantPledgeTaskCycleConf getOneByIdAndMerchantPledgeTaskId(Long cycleConfid, Long merchantPledgeTaskId) {
        LambdaQueryWrapper<MerchantPledgeTaskCycleConf> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MerchantPledgeTaskCycleConf::getId,cycleConfid);
        wrapper.eq(MerchantPledgeTaskCycleConf::getMerchantPledgeTaskId,merchantPledgeTaskId);
        return getOne(wrapper);
    }

    public List<MerchantPledgeTaskCycleConf> amendMerchantPledgeConfDataGroupByMerchantId() {
        LambdaQueryWrapper<MerchantPledgeTaskCycleConf> wrapper = new LambdaQueryWrapper<>();
        wrapper.groupBy(MerchantPledgeTaskCycleConf::getMerchantPledgeTaskId);
        return list(wrapper);
    }
}